#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include "book.h"
#include <stdlib.h>
#include "login.h"

bool AddList(P_Node_t p)
{
    if (p == NULL)
        return false;
    P_Node_t new_node = calloc(1, sizeof(Node_t));
    if (new_node == NULL)
    {
        printf("%s,%d:calloc fail\n", __FUNCTION__, __LINE__);
        return false;
    }
    printf("请输入书名：");
    scanf("%s", new_node->data.name);
    printf("请输入作者名：");
    scanf("%s", new_node->data.Author);
    printf("请输入JSBN：");
    scanf("%s", new_node->data.JSBN);
    printf("请输入出版社：");
    scanf("%s", new_node->data.Publisher);
    printf("请输入出版年份：");
    scanf("%d", &new_node->data.year);
    printf("请输入库存数量：");
    scanf("%d", &new_node->data.num);
    printf("请输入当前借出数量：");
    scanf("%d", &new_node->data.count);

    P_Node_t q = p;
    while (q->next != NULL)
    {
        q = q->next;
    }

    new_node->next = q->next;
    q->next = new_node;
    return true;
}

